#!/bin/sh

HOSTNAME=$(nvram get wan_hostname)
HOSTNAME=${HOSTNAME%%.*}
echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname

syslog_ip=$(nvram get log_ipaddr)
eval $(ipcalc.sh "$syslog_ip")
[ "$syslog_ip" = "$IP" ] || syslog_ip=""
syslogd -C16 ${syslog_ip:+-L -R $syslog_ip}
klogd
for i in /etc/init.d/S*; do
  $i start 2>&1
done | logger -s -p 6 -t '' &
